<?php
namespace home\controller;

use \core\Controller;

class commentController extends Controller{

    //新增加评论
    public function insert(){
        //接收数据
        $data['a_id']=(int)$_POST['a_id'];
        $data['c_comment']=trim($_POST['c_comment']);
        //合法性的验证
        if (empty($data['c_comment'])){
            $this->back("<script>alert('评论不能为空')</script>");
        }
        //补充数据
        @session_start();
        $data['u_id']=$_SESSION['user']['id'];
        $data['c_time']=time();

        $c=new \home\model\CommentModel();
        if ($c->autoInsert($data)){
            $this->back('<script>alert("评论成功")</script>');
        }else{
            $this->back('<script>alert("评论失败")</script>');
        }
    }
}
